home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / info-service / gopher / incoming / date+size.patch < prev    next >
Encoding:
Text File  |  1992-07-14  |  3.7 KB  |  121 lines

  1.  
  2. This is a patch to the unix gopher server, gopherd (version 1.01), that
  3. will append file dates and sizes to the title of gopher items.  
  4.  
  5. This is a feature that many users have requested of me, thinking that the
  6. client writers have "forgotten" to put in file date and size information
  7. in the display.   I recommend that all gopher servers add this patch.  It
  8. provides users with a clear idea of how recent a document is, and how big
  9. it is (will it fit on their computer? will it take a long time to 
  10. transfer?). 
  11.  
  12. This patch adds that information in a way that will
  13. not break any existing client program (it appears as just a longer
  14. title).  Smart new gopher clients can parse the title field to look
  15. for this date and size info, and reformat it or hide it at a user's
  16. preference.   This patch is designed to leave off the date+size info
  17. from items that really don't need it, like folders, query types, ftp
  18. types, etc., to give a less cluttered display.
  19.  
  20. You can easily apply this patch with Larry Wall's patch program (available at 
  21. many unix ftp sites), in this way, at the directory containing gopher1.01/
  22.    % patch -p < date+size.patch
  23.  
  24. -- Don Gilbert
  25.  
  26.  
  27. *** gopher1.01/Makefile.config    Thu Jun 11 18:57:54 1992
  28. --- biogoph/Makefile.config    Sun Jun 21 09:23:24 1992
  29. ***************
  30. *** 47,54 ****
  31.   #
  32.   # Add -DLOADRESTRICT if you want to restrict access based on load avg.
  33.   #     (Note you'll need to add -lkvm in SERVERLIBS)
  34.   
  35. ! SERVEROPTS    = # -DLOADRESTRICT
  36.   
  37.   
  38.   #--------------------------------------------------
  39. --- 48,56 ----
  40.   #
  41.   # Add -DLOADRESTRICT if you want to restrict access based on load avg.
  42.   #     (Note you'll need to add -lkvm in SERVERLIBS)
  43. + # -DFILESTATS to include file [date,size] in titles (dgg)
  44.   
  45. ! SERVEROPTS    = -DFILESTATS # -DLOADRESTRICT
  46.   
  47.   
  48.   #--------------------------------------------------
  49. diff -bwcr gopher1.01/gopherd/gopherd.c biogoph/gopherd/gopherd.c
  50. *** gopher1.01/gopherd/gopherd.c    Wed Jun 24 18:31:51 1992
  51. --- biogoph/gopherd/gopherd.c    Wed Jul  8 07:43:08 1992
  52. ***************
  53. *** 1183,1190 ****
  54. --- 1216,1269 ----
  55.   }
  56.   
  57.   
  58. + #ifdef FILESTATS
  59. + /* dgg addition, should be in gopherstruct.c ? */
  60. +  
  61. + void
  62. + GDaddDateNsize(gd)
  63. +   GopherDirObj *gd;
  64. + {
  65. +      int        fd, i;
  66. +      char         longname[256]; 
  67. +      STATSTR       buf;  /* gopherism == struct stat */
  68. +      GopherStruct  *ge;
  69. +      char       *cdate, *ti, *fp;
  70. +       
  71. +      for (i=0; i<GDgetTop(gd); i++) {
  72. +     ge= GDgetEntry(gd, i);
  73. +     switch (GSgetType(ge)) {
  74. +          case '1': /*** It's a directory ***/
  75. +          case '7': /*** It's an index ***/
  76. +          case 'f': /*** ftp link ***/
  77. +          case 'e': /*** exec link ***/
  78. +          case 'h': /*** www link ***/
  79. +          case 'w': /*** wais or whois link ***/
  80. +         break;
  81. +         
  82. +          case 's':  /*** It's a sound ***/
  83. +          case '0':  /*** It's a generic file ***/
  84. +          case '9':  /*** It's a binary file ***/
  85. +          default :
  86. +         fp= GSgetPath(ge);
  87. +         if (fp == 0) break; 
  88. +         /* !NOTE: listdir has done "rchdir(pathname)" at this call*/
  89. +         /* if (*fp != '/') fp= fp+1; -- vers0, skip type char */
  90. +         if ((fp = strrchr( fp, '/')) == 0) break;
  91. +         while (*fp == '/') fp= fp+1; /*  basename only */
  92. +         if (rstat(fp, &buf) == 0) {  
  93. +             cdate= ctime( &buf.st_ctime);
  94. +             cdate[ 7]= 0; cdate[10]= 0; cdate[24]= 0;
  95. +             sprintf( longname, "%s  [%s%s%s, %ukb]", GSgetTitle(ge),
  96. +               cdate+8,cdate+4,cdate+22, (buf.st_size+1023) / 1024);
  97. +             GSsetTitle(ge,longname);
  98. +             }
  99. +         break;
  100. +         }
  101. +     }       
  102. + }
  103. + #endif
  104.  
  105.  
  106.   /*
  107.   ** This function lists out what is in a particular directory.
  108.   ** it also outputs the contents of link files.
  109. ***************
  110. *** 1326,1330 ****
  111. --- 1405,1413 ----
  112.   
  113.         }
  114.        }
  115.      
  116. + #ifdef FILESTATS
  117. +       GDaddDateNsize( SortDir);   /* dgg */
  118. + #endif
  119. +   
  120.        GDsort(SortDir);
  121.